<template>
    <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="($router.push('/'))" />
    <van-row>
        <van-col span="6">
            <van-sidebar v-model="active">
                <van-sidebar-item v-for="item in classDate" :title="item.cat_name" />
            </van-sidebar>
        </van-col>
        <van-col span="18">
            <div v-for="items in classDate[active]?.children">
                <h4>{{ items.cat_name }}</h4>
                <router-link :to="'/goods/'+items.cat_name">
                    <van-grid :column-num="4">
                        <van-grid-item v-for="itemall in items.children" :key="value" :icon="itemall.cat_icon"
                            :text="itemall.cat_name" />
                    </van-grid>
                </router-link>

            </div>
        </van-col>
    </van-row>
</template>

<script setup>
import { ref } from 'vue'
let classDate = ref([])
import { classApi } from '@/api/api'
classApi().then(res => {
    console.log('分类数据', res)
    classDate.value = res.data.message
})
let active = ref(0)
</script>

<style lang="scss" scoped></style>